package com.wash.shoes.domain.dy.request;

import com.alibaba.fastjson2.JSONObject;
import com.wash.shoes.domain.dy.model.QueryBookDto;
import com.wash.shoes.domain.dy.model.QueryOrderDto;
import com.wash.shoes.domain.dy.model.QueryOrderVo;
import com.wash.shoes.entity.BrandPo;
import com.wash.shoes.entity.OrderPo;
import com.wash.shoes.mapper.BrandMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author lijianguo
 * @Date 29/03/2025 08:08
 *  https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/locallife/general-ability/self-operated-trading/query-info/query-order
 * /生活服务/通用能力/生活服务交易系统（账号融合版/查询接口/
 * 查询接口
 *  1-查询订单信息
 *  2-查询券状态信息
 *  3-查询CPS信息
 * 预下单
 *  4-用户取消预约
 *  5-查询预约单信息
 *  6-预约接单超时回调
 *  7-预约取消/完成通知
 **/
@Log4j2
@Component
public class DyOrderRequest extends DyBaseRequest {

    /**
     * 查询接口 查询订单信息
     */
    public QueryOrderVo queryOrder(OrderPo orderPo) {

        QueryOrderDto queryOrderDto = new QueryOrderDto();
        queryOrderDto.setOrder_id(orderPo.getMtOrderId());
        BrandPo brandPo = getBrandPo(orderPo);
        String result = postRequest(DyConstant.QUERY_ORDER, queryOrderDto,brandPo.getAccountid());
        JSONObject jsonObject = JSONObject.parseObject(result);
        return JSONObject.parseObject(jsonObject.getString("data"), QueryOrderVo.class);
    }


    @Autowired
    private BrandMapper brandMapper;

    /**
     * 查询接口 查询订单信息
     */
    public JSONObject closeOrder(OrderPo orderPo) {

        QueryOrderDto queryOrderDto = new QueryOrderDto();
        queryOrderDto.setOrder_id(orderPo.getMtOrderId());
        BrandPo brandPo = getBrandPo(orderPo);
        String result = postRequest(DyConstant.CLOSE_ORDER, queryOrderDto,brandPo.getAccountid());
        return JSONObject.parseObject(result);
    }


}
